package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.model.enums.InfoTypeEnum;
import tx.bj12320.model.enums.ToPublishInfoTypeEnum;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_INFOISSUE")
public class Infoissue extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "Infoissue";
	public static final String ALIAS_INFOISSUE_ID = "infoissueId";
	public static final String ALIAS_USER_INFO_ID = "userInfoId";
	public static final String ALIAS_INFO_TITLE = "标题";
	public static final String ALIAS_ISSUE_DATE = "发布日期";
	public static final String ALIAS_INFO_CONTENT = "内容";
	public static final String ALIAS_ATTACHMENT_NAME = "附件名称";
	public static final String ALIAS_ATTACHMENT_FILE = "附件文件";
	public static final String ALIAS_INFO_TYPE = "信息类别";
	public static final String ALIAS_IS_MAIL = "isMail";
	public static final String ALIAS_MAIL_RECEIVER_ID = "mailReceiverId";
	public static final String ALIAS_MAIL_RECEIVER_TYPE = "mailReceiverType";
	public static final String ALIAS_REPLY_INFOISSUE_ID = "replyInfoissueId";
	public static final String ALIAS_IS_READ = "isRead";
	public static final String ALIAS_READ_DATE = "readDate";
	public static final String ALIAS_MAIL_RECEIVER_SUM = "mailReceiverSum";
	public static final String ALIAS_IS_MAIN_MAIL = "isMainMail";
	public static final String ALIAS_MAIN_MAIL_INFOISSUE_ID = "mainMailInfoissueId";
	public static final String ALIAS_IS_ADOPT = "是否采纳";

	//date formats
	public static final String FORMAT_ISSUE_DATE = DATE_FORMAT;
	public static final String FORMAT_READ_DATE = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * infoissueId       db_column: INFOISSUE_ID
     */

	private Long infoissueId;
    /**
     * userInfoId       db_column: USER_INFO_ID
     */

	private Long userInfoId;
    /**
     * infoTitle       db_column: INFO_TITLE
     */
	@Length(max=200)
	private java.lang.String infoTitle;
    /**
     * issueDate       db_column: ISSUE_DATE
     */

	private java.util.Date issueDate;
    /**
     * infoContent       db_column: INFO_CONTENT
     */
	@Length(max=4000)
	private java.lang.String infoContent;
    /**
     * attachmentName       db_column: ATTACHMENT_NAME
     */
	@Length(max=200)
	private java.lang.String attachmentName;
    /**
     * attachmentFile       db_column: ATTACHMENT_FILE
     */
	@Length(max=200)
	private java.lang.String attachmentFile;
    /**
     * infoType       db_column: INFO_TYPE
     */

	private Long infoType;
    /**
     * isMail       db_column: IS_MAIL
     */

	private Long isMail;
    /**
     * mailReceiverId       db_column: MAIL_RECEIVER_ID
     */

	private Long mailReceiverId;
    /**
     * mailReceiverType       db_column: MAIL_RECEIVER_TYPE
     */
	@Length(max=200)
	private java.lang.String mailReceiverType;
    /**
     * replyInfoissueId       db_column: REPLY_INFOISSUE_ID
     */

	private Long replyInfoissueId;
    /**
     * isRead       db_column: IS_READ
     */

	private Long isRead;
    /**
     * readDate       db_column: READ_DATE
     */

	private java.util.Date readDate;
    /**
     * mailReceiverSum       db_column: MAIL_RECEIVER_SUM
     */

	private Long mailReceiverSum;
    /**
     * isMainMail       db_column: IS_MAIN_MAIL
     */

	private Long isMainMail;
    /**
     * mainMailInfoissueId       db_column: MAIN_MAIL_INFOISSUE_ID
     */

	private Long mainMailInfoissueId;
	 /**
     * isAdopt       db_column: IS_ADOPT
     */

	private Long isAdopt;
	//columns END


	public Infoissue(){
	}

	public Infoissue(
		Long infoissueId
	){
		this.infoissueId = infoissueId;
	}



	public void setInfoissueId(Long value) {
		this.infoissueId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_INFOISSUE_SEQU")
    @SequenceGenerator(name="BJ12320_INFOISSUE_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_INFOISSUE_SEQU")
	@Column(name = "INFOISSUE_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 0)
	public Long getInfoissueId() {
		return this.infoissueId;
	}

	@Column(name = "USER_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	public void setUserInfoId(Long value) {
		this.userInfoId = value;
	}

	@Column(name = "INFO_TITLE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getInfoTitle() {
		return this.infoTitle;
	}

	public void setInfoTitle(java.lang.String value) {
		this.infoTitle = value;
	}

	@Transient
	public String getIssueDateString() {
		return DateConvertUtils.format(getIssueDate(), FORMAT_ISSUE_DATE);
	}
	public void setIssueDateString(String value) {
		setIssueDate(DateConvertUtils.parse(value, FORMAT_ISSUE_DATE,java.util.Date.class));
	}

	@Column(name = "ISSUE_DATE", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getIssueDate() {
		return this.issueDate;
	}

	public void setIssueDate(java.util.Date value) {
		this.issueDate = value;
	}

	@Column(name = "INFO_CONTENT", unique = false, nullable = true, insertable = true, updatable = true, length = 4000)
	public java.lang.String getInfoContent() {
		return this.infoContent;
	}

	public void setInfoContent(java.lang.String value) {
		this.infoContent = value;
	}

	@Column(name = "ATTACHMENT_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getAttachmentName() {
		return this.attachmentName;
	}

	public void setAttachmentName(java.lang.String value) {
		this.attachmentName = value;
	}

	@Column(name = "ATTACHMENT_FILE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getAttachmentFile() {
		return this.attachmentFile;
	}

	public void setAttachmentFile(java.lang.String value) {
		this.attachmentFile = value;
	}

	@Column(name = "INFO_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getInfoType() {
		return this.infoType;
	}

	public void setInfoType(Long value) {
		this.infoType = value;
	}

	@Column(name = "IS_MAIL", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsMail() {
		return this.isMail;
	}

	public void setIsMail(Long value) {
		this.isMail = value;
	}

	@Column(name = "MAIL_RECEIVER_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getMailReceiverId() {
		return this.mailReceiverId;
	}

	public void setMailReceiverId(Long value) {
		this.mailReceiverId = value;
	}

	@Column(name = "MAIL_RECEIVER_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getMailReceiverType() {
		return this.mailReceiverType;
	}

	public void setMailReceiverType(java.lang.String value) {
		this.mailReceiverType = value;
	}

	@Column(name = "REPLY_INFOISSUE_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getReplyInfoissueId() {
		return this.replyInfoissueId;
	}

	public void setReplyInfoissueId(Long value) {
		this.replyInfoissueId = value;
	}

	@Column(name = "IS_READ", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsRead() {
		return this.isRead;
	}

	public void setIsRead(Long value) {
		this.isRead = value;
	}

	@Transient
	public String getReadDateString() {
		return DateConvertUtils.format(getReadDate(), FORMAT_READ_DATE);
	}
	public void setReadDateString(String value) {
		setReadDate(DateConvertUtils.parse(value, FORMAT_READ_DATE,java.util.Date.class));
	}

	@Column(name = "READ_DATE", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getReadDate() {
		return this.readDate;
	}

	public void setReadDate(java.util.Date value) {
		this.readDate = value;
	}

	@Column(name = "MAIL_RECEIVER_SUM", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getMailReceiverSum() {
		return this.mailReceiverSum;
	}

	public void setMailReceiverSum(Long value) {
		this.mailReceiverSum = value;
	}

	@Column(name = "IS_MAIN_MAIL", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsMainMail() {
		return this.isMainMail;
	}

	public void setIsMainMail(Long value) {
		this.isMainMail = value;
	}

	@Column(name = "MAIN_MAIL_INFOISSUE_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getMainMailInfoissueId() {
		return this.mainMailInfoissueId;
	}

	@Column(name = "IS_ADOPT", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsAdopt() {
		return this.isAdopt;
	}

	public void setIsAdopt(Long value) {
		this.isAdopt = value;
	}


	public void setMainMailInfoissueId(Long value) {
		this.mainMailInfoissueId = value;
	}


	private UserInfo userInfo;
	public void setUserInfo(UserInfo userInfo){
		this.userInfo = userInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "USER_INFO_ID",nullable = false, insertable = false, updatable = false)
	})
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("InfoissueId",getInfoissueId())
			.append("UserInfoId",getUserInfoId())
			.append("InfoTitle",getInfoTitle())
			.append("IssueDate",getIssueDate())
			.append("InfoContent",getInfoContent())
			.append("AttachmentName",getAttachmentName())
			.append("AttachmentFile",getAttachmentFile())
			.append("InfoType",getInfoType())
			.append("IsMail",getIsMail())
			.append("MailReceiverId",getMailReceiverId())
			.append("MailReceiverType",getMailReceiverType())
			.append("ReplyInfoissueId",getReplyInfoissueId())
			.append("IsRead",getIsRead())
			.append("ReadDate",getReadDate())
			.append("MailReceiverSum",getMailReceiverSum())
			.append("IsMainMail",getIsMainMail())
			.append("MainMailInfoissueId",getMainMailInfoissueId())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getInfoissueId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof Infoissue == false) return false;
		if(this == obj) return true;
		Infoissue other = (Infoissue)obj;
		return new EqualsBuilder()
			.append(getInfoissueId(),other.getInfoissueId())
			.isEquals();
	}

	@Transient
	public String getInfoTypeString(){
		return infoType==null?"":InfoTypeEnum.getByCode(infoType).getDesc();
	}

	private Long isInfoToPublish;

	@Column(name = "IS_INFO_TO_PUBLISH", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsInfoToPublish() {
		return isInfoToPublish;
	}

	public void setIsInfoToPublish(Long isInfoToPublish) {
		this.isInfoToPublish = isInfoToPublish;
	}

	@Transient
	public String getToPublishInfoTypeString(){
		return infoType==null?"":ToPublishInfoTypeEnum.getByCode(infoType).getDesc();
	}




}

